package org.msd.controller;

import org.apache.ibatis.annotations.Param;
import org.msd.model.Commodity;
import org.msd.service.iml.ZoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;

@Controller
@RequestMapping("zoom")
public class ZoomExhibiton {

    @Autowired
    private ZoomService zoomService;

    @RequestMapping("getPage")
    @ResponseBody
    public List<Commodity> getPage(@Param("person") String person) {//
        //输出房间的所有数据
        List<Commodity> commodities;
        if (StringUtils.isEmpty(person)) {//判断是不是空 是空就输出所有
            commodities = zoomService.RoomQuer();
        } else {
            commodities = zoomService.Fuzzyquery(person);//不是就模糊查询
        }

        return commodities;
    }


    @RequestMapping("deall")
    @ResponseBody
    public String  DeseAll(@RequestParam("commodityid")int commodityid){
        return zoomService.deleteZoom(commodityid) == 1 ? "删除成功" : "删除失败";
       }




}

